package com.ruoyi.web.controller.spoken;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.SpokenCourseTag;
import com.ruoyi.system.service.ISpokenCourseTagService;
import com.ruoyi.system.service.ISpokenCourseTagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "课程分类管理")
@RequestMapping("/spoken/courseTag")
@RestController
public class CourseTagController extends BaseController {

    @Autowired
    ISpokenCourseTagService courseTagService;

    @ApiOperation("课程分类列表")
    @GetMapping("/list")
    public TableDataInfo list(SpokenCourseTag courseTag){
        startPage();
        return getDataTable(courseTagService.selectList(courseTag));
    }

    @ApiOperation("添加课程分类")
    @PostMapping
    public AjaxResult add(@RequestBody SpokenCourseTag courseTag){
        return success(courseTagService.insert(courseTag));
    }

    @ApiOperation("查询课程分类")
    @GetMapping("/{cTagId}")
    public AjaxResult getbyId(@PathVariable Long cTagId){
        return success(courseTagService.selectById(cTagId));
    }

    @ApiOperation("修改课程分类")
    @PutMapping
    public AjaxResult edit(@RequestBody SpokenCourseTag courseTag){
        return success(courseTagService.update(courseTag));
    }

    @ApiOperation("删除课程分类")
    @DeleteMapping("/{cTagId}")
    public AjaxResult remove(@PathVariable Long cTagId){
        return success(courseTagService.delete(cTagId));
    }

}
